home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 9
/
009.d81
/
dos #20
< prev
next >
Wrap
Text File
|
2022-08-26
|
2KB
|
149 lines
DOS & DON'TS -- Part 20
=== = ====== ==== ==
By Jimmy Weiler
You should be tired of ordinary
SEQ files by now -- we've covered how
to open, write, read, and append them.
There's not a lot left you can do with
them unless you're a lot more
sophisticated than we are.
This time let's dig into RELative
files. (On most OTHER computers
they're called random access... but
Commodore uses 'random access' to
describe user-controlled sector-by-
sector disk i/o's so they had to
call this type of file something
else.)
SEQuential files can be thought of
as one big chunk of data, like a
scroll. Relative files are more like
a bunch of little chunks, all the
same size, like the index cards in
your recipe file, or the pages in a
book. The disadvantage of SEQ files
is that, just like a scroll, you have
to start at the beginning and 'unroll'
the contents in the order they were
written. Relative files overcome
this disadvantage by allowing you to
access any individual piece of the
file directly, without scanning over
the rest of the file.
Graphically the data in a sequential
and a random file might be represented
like this:
Sequential file:
data/more data/even more data/& some m
ore data/and the end
Relative file:
/data //more data /
/even more data //& some more data /
/and the end /
As you can see, the data is packed
into the SEQ file one bit after
another, in five records of unequal
sizes. In the REL file, there are
still five records, but they are all
the same size. Because all the
records are equally large, DOS is able
calculate the location on the disk of
any piece of data relative to the
start of the file and access it
directly.
SEQ files are useful when you are
dealing with information that will all
be read into the computer's memory at
one time -- letters, small data files,
etc.
REL files are useful when you have
too much information to read into
memory at once, or when you only want
to access a little of it at a time.
This makes them useful for business
and record keeping applications where
small amounts of data are to be kept
'on file' for lots of people.
Enough generalities -- let's get
right into using RELative files.
We'll cover opening, closing, writing,
and reading them.
-------- Continued in Part 21 --------